package com.atguigu.auth.controller;

import com.atguigu.auth.mapper.OaProcessMapper;
import com.atguigu.auth.service.OaProcessService;
import com.atguigu.common.Result;
import com.atguigu.vo.process.ProcessQueryVo;
import com.atguigu.vo.process.ProcessVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ProcessController
 * Package: com.atguigu.auth.controller
 * Description:
 *
 * @Author 蹇泽阳
 * @Create 2023/11/21 20:03
 * @Version 1.0
 */
@Api(tags = "审批流管理")
@RestController
@RequestMapping(value = "/admin/process")
@SuppressWarnings({"unchecked", "rawtypes"})
public class ProcessController {
  
  @Autowired
  private OaProcessService processService;
  
  @Autowired
  private OaProcessMapper processMapper;
  
  @PreAuthorize("hasAuthority('bnt.process.list')")
  @ApiOperation(value = "获取分页列表")
  @GetMapping("{page}/{limit}")
  public Result index(
      @ApiParam(name = "page", value = "当前页码", required = true)
      @PathVariable Long page,
      
      @ApiParam(name = "limit", value = "每页记录数", required = true)
      @PathVariable Long limit,
      
      @ApiParam(name = "processQueryVo", value = "查询对象", required = false)
      ProcessQueryVo processQueryVo) {
    Page<ProcessVo> pageParam = new Page<>(page, limit);
    IPage<ProcessVo> pageModel = processMapper.selectPage(pageParam, processQueryVo);
    return Result.ok(pageModel);
  }
  
}
